/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import { Project } from '@ohos/hvigor';

import { CoreProjectModelImpl } from '../../model/project/core-project-model-impl.js';
import { LegacyProjectModelImpl } from '../../model/project/legacy-project-model-impl.js';
import { DependencyManager } from '../../project/dependency/dependency-manager.js';
import { ProjectTaskService } from '../../tasks/service/project-task-service.js';
import { AbstractProjectPlugin } from '../common/abstract-project-plugin.js';

/**
 * 对外暴露app级别的接口和任务的plugin
 *
 * @since 2021/12/16
 */
export class LegacyAppPlugin extends AbstractProjectPlugin {
  constructor(project: Project) {
    super(project);
    const legacyProjectModel = new LegacyProjectModelImpl(project) as CoreProjectModelImpl;
    legacyProjectModel.initSubProject();
    this._projectModel = legacyProjectModel;
  }

  initTaskService(): void {
    const dependencyManager = new DependencyManager(true, this._projectModel!);
    this._taskService = new ProjectTaskService(this._project, this._projectModel!, dependencyManager, true);
  }
}
